import 'package:flutter/material.dart';
import 'package:flutter_app/pages/guide/guide_page.dart';
import 'package:flutter_app/pages/router/first_page.dart';
import 'package:flutter_app/pages/router/second_page.dart';
import 'package:flutter_app/pages/user/user_page.dart';
import 'package:flutter_app/router/route_names.dart';
import 'package:go_router/go_router.dart';

class AppRouter {
  static final GoRouter router = GoRouter(
    initialLocation: RouteNames.guide,
    routes: [
      GoRoute(path: RouteNames.guide, builder: (context, state) => GuidePage()),
      GoRoute(path: RouteNames.user, builder: (context, state) => UserPage()),
      GoRoute(
        path: RouteNames.first,
        pageBuilder: (context, state) {
          Map<String, dynamic>? extra = state.extra as Map<String, dynamic>?;
          return MaterialPage(child: FirstPage(title: extra?['title']));
        },
      ),
      GoRoute(
        path: RouteNames.second,
        builder: (context, state) =>
            SecondPage(title: state.pathParameters['title']),
      ),
    ],
  );

  // static Route<dynamic>? generateRoute(RouteSettings settings) {
  //   Map<String, dynamic>? arguments;
  //   if (settings.arguments != null) {
  //     arguments = settings.arguments as Map<String, dynamic>;
  //   }
  //   switch (settings.name) {
  //     case RouteNames.guide:
  //       return NoAnimRouteBuilder(GuidePage(), settings);
  //     case RouteNames.tabNavigator:
  //       return NoAnimRouteBuilder(
  //         // TabNavigatorPage(tab: arguments?["tab"] ?? 0),
  //         Container(),
  //         settings,
  //       );
  //     default:
  //       return CupertinoPageRoute(
  //         builder: (_) =>
  //             Scaffold(body: Center(child: Text('页面正在开发中 ${settings.name}'))),
  //       );
  //   }
  // }
}
